/*
 * CPU.h
 *
 *  Created on: 2013-11-12
 *      Author: james
 */
#include "Process.h"
#include "FinishedQ.h"
#include "PriorityQ.h"
#include <ctime>
#include <iostream>
#include "RuntimeParameters.h"

#ifndef CPU_H_
#define CPU_H_

class CPU {

public:
	virtual ~CPU();
	CPU(int timeQuantum, int cpuID);
	void run();
	int getCpuID();
	void displayCpuSummary();
	void calculateTotalCpuLifetime();

private:
	int cpuID;
	Process* process;
	void runProcess();
	bool hasWorkLeft();
	bool isCpuBound();
	bool isIOBound();
	void tick();
	void moveToNextOperation();
	void addProcessToCPU(Process *process);
	void pushToPriorityQ();
	void displayOperationSummary();
	int currentProcessRuntime;
	int timeQuantum;
	double timeCounter;
	PriorityQ* prioQ;
	std::clock_t CPUSpawnTime;
	std::clock_t startTime;
	std::clock_t stopTime;
	double totalCpuLIfetime;
	double runningTime;
	void startCpuTimer();
	void stopCpuTimer();
};

#endif /* CPU_H_ */
